package emulator.hardware.io.peripherals;

public class JoystickButton implements Button {

	private int index;
	private Joystick joystick;

	JoystickButton(int index, Joystick joystick) {
		this.index = index;
		this.joystick = joystick;
	}

	@Override
	public void press() {
		joystick.updateButton(index, false);
	}

	@Override
	public void release() {
		joystick.updateButton(index, true);
	}
	
	public boolean getState() {
		return !joystick.getState(index);
	}

}
